new_event->scroll.y_root = 0.;
new_event->scroll.delta_x = 0.;
new_event->scroll.delta_y = 0.;
+ new_event->scroll.is_stop = FALSE;
break;
case GDK_ENTER_NOTIFY:
case GDK_LEAVE_NOTIFY:
return fetched;
}
+/**
+ * gdk_event_is_scroll_stop_event
+ * @event: a #GdkEvent
+ *
+ * Check whether a scroll event is a stop scroll event. Scroll sequences
+ * with smooth scroll information may provide a stop scroll event once the
+ * interaction with the device finishes, e.g. by lifting a finger. This
+ * stop scroll event is the signal that a widget may trigger kinetic
+ * scrolling based on the current velocity.
+ *
+ * Stop scroll events always have a a delta of 0/0.
+ *
+ * Returns: %TRUE if the event is a scroll stop event
+ *
+ * Since: 3.20
+ */
+gboolean
+gdk_event_is_scroll_stop_event (const GdkEvent *event)
+{
+ return event->scroll.is_stop;
+}
+
/**
* gdk_event_get_axis:
* @event: a #GdkEvent
/* Specific to the scroll event */
gdouble delta_x, delta_y;
int32_t discrete_x, discrete_y;
+ gint8 is_scroll_stop;
};
struct _GdkWaylandSeat
static void
flush_smooth_scroll_event (GdkWaylandSeat *seat,
gdouble delta_x,
- gdouble delta_y)
+ gdouble delta_y,
+ gboolean is_stop)
{
GdkEvent *event;
event->scroll.direction = GDK_SCROLL_SMOOTH;
event->scroll.delta_x = delta_x;
event->scroll.delta_y = delta_y;
+ event->scroll.is_stop = is_stop;
_gdk_wayland_display_deliver_event (seat->display, event);
}
flush_scroll_event (GdkWaylandSeat *seat,
GdkWaylandPointerFrameData *pointer_frame)
{
+ gboolean is_stop = FALSE;
+
if (pointer_frame->discrete_x || pointer_frame->discrete_y)
{
GdkScrollDirection direction;
flush_discrete_scroll_event (seat, direction);
}
+ /* Axes can stop independently, if we stop on one axis but have a
+ * delta on the other, we don't count it as a stop event.
+ */
+ if (pointer_frame->is_scroll_stop &&
+ pointer_frame->delta_x == 0 &&
+ pointer_frame->delta_y == 0)
+ is_stop = TRUE;
+
flush_smooth_scroll_event (seat,
pointer_frame->delta_x,
- pointer_frame->delta_y);
+ pointer_frame->delta_y,
+ is_stop);
pointer_frame->delta_x = 0;
pointer_frame->delta_y = 0;
pointer_frame->discrete_x = 0;
pointer_frame->discrete_y = 0;
+ pointer_frame->is_scroll_stop = FALSE;
}
static void
g_return_if_reached ();
}
+ pointer_frame->is_scroll_stop = TRUE;
+
GDK_NOTE (EVENTS,
g_message ("axis stop, seat %p", seat));
}